package com.power.controller;

import com.alibaba.fastjson.JSON;
import com.power.ov.ResultDataTable;
import com.power.service.impl.InspeServiceimpl;
import com.power.service.inspeService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

/**
 * Created with IntelliJ IDEA.
 * User: 李辽
 * Date: 2020/10/10 17:08
 * Description:通过任务编号、线路编号、任务状态查询巡检信息
 * Version: V1.0
 */
@WebServlet("/SearchInspection.do")
public class SearchInspection extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String task_id = request.getParameter("task_id");
        String line_number = request.getParameter("line_number");
        String state_name = request.getParameter("state_name");
        int state_id=0;
        if(state_name!=null && !state_name.equals("")){
            state_id = Integer.parseInt(state_name);
        }
        response.setContentType("application/json;charset=utf-8");
        ResultDataTable resultDataTable = null;
        inspeService inspeService = new InspeServiceimpl();
        try {
            resultDataTable =  inspeService.SearchInspection(task_id,line_number,state_id);
            response.getWriter().write(JSON.toJSONString(resultDataTable));
            response.getWriter().flush();
            response.getWriter().close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}



























